<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="http://res.wisedu.com/fe_components/iconfont/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="http://res.wisedu.com/fe_components/jqwidget/blue/bh.min.css" />
    <link rel="stylesheet" type="text/css" href="http://res.wisedu.com/fe_components/jqwidget/blue/bh-scenes.min.css" />
    <link rel="stylesheet" type="text/css" href="http://res.wisedu.com/bower_components/animate.css/animate.min.css" />
    <link rel="stylesheet" type="text/css" href="http://res.wisedu.com/bower_components/sentsinLayer/skin/layer.css" />
    <link rel="stylesheet" type="text/css" href="http://res.wisedu.com/fe_components/bhtc/bhtc-datetimepicker/css/blue/bhtc-datetimepicker.css" />
    <script src="http://res.wisedu.com/fe_components/jquery-1.11.3.js"></script>
    <!-- weekUnitTable -->
    <link rel="stylesheet" type="text/css" href="./weekUnitTableViewer.css" />
    <script src="./weekUnitTableViewer.js"></script>
    <script src="./html2canvas.js"></script>
</head>

<body>
    <a href="javascript:void(0)" class="bh-btn bh-btn-small bh-btn-primary" id="down_button">下载</a>
    <div id="testDiv" class="d" style="width:800px;margin:10px;"></div>
    <script type="text/javascript">
    var weekUnitTableViewer = new WeekUnitTableViewer({
        container: '.d'
    });
    weekUnitTableViewer.render();

    var results = [{
        unit: "1",
        week: "1",
        content: "100人"
    }, {
        unit: "3",
        week: "3",
        content: "200人"
    }, {
        unit: "4",
        week: "3",
        content: "100人"
    }, {
        unit: "1",
        week: "2",
        content: "500人"
    }];

    weekUnitTableViewer.setResults(results, function() {
        html2canvas($('#testDiv').find('table'), {
            onrendered: function(canvas) {
                //document.body.appendChild(canvas);
                $('#down_button').attr('href', canvas.toDataURL());
                $('#down_button').attr('download', 'myjobdeer.png');
            }
        });
    });
    </script>
</body>

</html>
